﻿using B.S.GridManage.Api.Write.Application.Command.PhsicalGrid;
using B.S.GridManage.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.GridManage.Api.Write.Controllers
{
    /// <summary>
    /// PhysicalGrid Controller
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PhysicalGridController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// Regist Media from Ctor
        /// </summary>
        /// <param name="mediator"></param>
        public PhysicalGridController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 创建物理网格的接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreatePhysicalGrid(CreatePhysicalGridCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改物理网格的接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdatePhysicalGrid(UpdatePhysicalGridCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 删除物理网格的接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public  Task<ApiResult<int>> DelPhysicalGrid(DelPhysicalGridCommand request) {

            return mediator.Send(request);
        }
    }
}
